package net.sshiffon.logging
import org.apache.log4j.Logger
import org.codehaus.groovy.runtime.StackTraceUtils;

/**
 * Logger for uncaught exceptions
 * 
 * @author amir
 * @see griffon.util.GriffonExceptionHandler
 */

class LoggingExceptionHandler implements java.lang.Thread.UncaughtExceptionHandler {
    static Logger logger = Logger.getLogger(LoggingExceptionHandler.class)

    @Override
	public void uncaughtException(Thread t, Throwable e)
    {
    		Throwable sanitized= StackTraceUtils.deepSanitize(e);
            logger.error("Uncaught exception '${e.message}'", sanitized);
            //throw new RuntimeException("rethrowing uncaught exception", sanitized);
    }
}